const {
    BrowserWindow
} = require('electron')
const path = require("path")
class ProviderWindowController {
    constructor(isOpen = true) {
        this.isOpen = isOpen;
        this.window = null;
        this.windowConfig = {
            width: 800,
            height: 600,
            frame: false,
            webPreferences: {
                nodeIntegration: true,
                nodeIntegrationInWorker: true,
                nodeIntegrationInSubFrames: true,
            }
        }
        if (isOpen) {
            this.createWindow()
        }
    }
    createWindow() {
        this.window = new BrowserWindow(this.windowConfig);
        // console.log(__dirname, __static, process.env, root)
        let src = path.join(__dirname, "../view/index.html")
        src = src.substring(src.indexOf("src"))
        this.window.loadURL(`http://localhost:${process.env.PORT}/${src}`, )
    }
}

module.exports = ProviderWindowController